package com.yj.user.jackson;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yj.user.pojo.User;

public class JacksonDemo {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        User user = new User().setId(1).setName("张三").setAddress("湖南长沙");
        String s = objectMapper.writeValueAsString(user);
        System.out.println(s);
        User user1 = objectMapper.readValue(s, User.class);
        System.out.println(user1);



    }
}
